# encoding: utf-8
__author__ = 'binbin'
__date__ = '2018/10/13 0013 20:26'

import logging
from redis import StrictRedis


class Config(object):

    DEBUG = True

    LOGGIONG_LEVEL = logging.DEBUG

    SECRET_KEY = 'iajsfjjaksfkjashfkajshfjkaslf'

    SQLALCHEMY_DATABASE_URI = "mysql://root:@127.0.0.1:3306/ihome"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 8080
    REDIS_DB = 1

    # 配置session数据存储到redis数据库
    SESSION_TYPE = 'redis'
    # 指定存储session数据的redis的位置
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB)
    # 开启session数据的签名，意思是让session数据不以明文形式存储
    SESSION_USE_SIGNER = True
    # 設置session的会话的超时时长 ：一天,全局指定
    PERMANENT_SESSION_LIFETIME = 3600 * 24

class DevelopConfig(Config):
    """开发阶段下的配置子类"""
    #logging等级
    LOGGIONG_LEVEL=logging.DEBUG

class UnitTestConfig(Config):
    """单元测试配置子类"""
    # logging等级
    LOGGIONG_LEVEL = logging.DEBUG
    SQLALCHEMY_DATABASE_URI = 'mysql://root:@127.0.0.1:3306/ihome_test'

class ProductionConfig(Config):
    """生产环境下配置子类"""
    # logging等级
    LOGGIONG_LEVEL = logging.WARNING
    DEBUG = False
    SQLALCHEMY_DATABASE_URI = 'mysql://root:@127.0.0.1:3306/ihome'
    REDIS_HOST = '127.0.0.1'

#工厂函数原材料
configs={
    'default'    :Config,
    'develop'    :DevelopConfig,
    'unittest'   :UnitTestConfig,
    'production' :ProductionConfig
}